import { TableShape } from "@/components/c14-Table";
import { BasePagesUrls, PagesNavigation } from "../pages/pagesTypes";
import { ImageStringFormat, VideoStringFormat } from "./mediaTypes";
import { DateShape, TimeShape } from "./timeTypes";

export type ElementTypesShapeList =
  | {
      type: "title";
      content: string;
    }
  | {
      type: "underlineBTN";
      content: string;
      link: string;
    }
  | {
      type: "table";
      content: [Omit<TableShape, "secondRowHighlighted">];
    }
  | {
      type: "blueBGBTN";
      typeUse: "ordinary";
      content: string;
      link: "";
    }
  | {
      type: "blueBGBTN";
      typeUse: "nav";
      content: string;
      lat: string;
      lon: string;
      address: string;
    }
  | {
      type: "location";
      lat: string;
      lon: string;
      address: string;
    }
  | {
      type: "unorderedList";
      content: string;
    }
  | {
      type: "picture";
      content: ImageStringFormat;
    }
  | {
      type: "video";
      content: {
        value: VideoStringFormat;
        attWidth: number;
        attHeight: number;
      }[];
    }
  | {
      type: "content";
      content: string;
    }
  | {
      type: "atlas";
      content: {
        value: ImageStringFormat;
      }[];
    }
  | TabSectionDetailShape;

export type TabSectionDetailShape = {
  type: "labelPage";
  content: {
    title: string;
    child: ElementTypesShapeList[];
  }[];
};

export type TabSectionData = TabSectionDetailShape[];

export enum ApiItemTypeMapping {
  Course = 0,
  CourseDiscovery = 1,
  Talk = 2,
  Exhibition = 3,
  ShopItem = 4,
}

export type EventRecommendationShape = {
  aboutId: number;
  name: string;
  cover: string;
  typeCourse: ApiItemTypeMapping;
  typeName: string;
  labelColor: string;
  price: number;
  sharePoster?: string;
};

export type PhysicalItemRecommendationShape = {
  aboutId: number;
  name: string;
  cover: string;
  sharePoster: string;
  typeCourse: ApiItemTypeMapping;
  price: number;
  labelColor: string;
};

// Shared by Calendar and multiple User-views
export type ItemListingCardShape = {
  id?: number;
  productId?: number;
  imagePath: string;
  themeColor: string;
  tagText: string;
  upperRightText?: string;
  name: string;
  date?: DateShape;
  startTime?: TimeShape;
  endTime?: TimeShape;
  price?: number;
  startDate?: DateShape;
  endDate?: DateShape;
  mainType?: ApiItemTypeMapping;
  avaliable?: boolean;
  orderNo?: string;
  status?: boolean;
};

export type AddressPayload = {
  courseAddress: string;
  courseAddressInfo: string;
  lat: string;
  lon: string;
  dest: string;
};

export type AddressShape = {
  address: AddressPayload;
};

export type AccordionPayloadShape = {
  title: string;
  content: Array<
    | ({ text: string } & { type: "text"; link?: never })
    | ({ text: string } & { type: "inline-text"; link?: never })
    | ({ text: string } & {
        type: "inline-link";
        linkData:
          | {
              link: PagesNavigation;
              type: "navigate";
            }
          | {
              link: BasePagesUrls;
              type: "tab";
            };
      })
  >;
};
